#!/bin/bash

echo "=== 重新创建正确的项目文件 ==="

# 备份原文件
cp cbp2make_aicoder_wx32_64.cbp cbp2make_aicoder_wx32_64.cbp.old

# 创建新的正确配置
cat > cbp2make_aicoder_wx32_64.cbp << 'CPBEOF'
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="cbp2make AICoder wx32_64" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Default">
<Option output="bin/cbp2make_ai_wx32_64" prefix_auto="1" extension_auto="1" />
<Option working_dir="bin" />
<Option object_output=".objs/wx32_64" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-Wall" />
<Add option="-std=c++11" />
<Add option="-DAICODER_ENHANCED" />
<Add option="-m64" />
<Add option="-D__WXMSW__" />
<Add option="-DwxUSE_UNICODE" />
</Compiler>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-std=c++11" />
<Add option="-DAICODER_ENHANCED" />
<Add option="-m64" />
<Add option="-D__WXMSW__" />
<Add option="-DwxUSE_UNICODE" />
<!-- 正确的包含路径 -->
<Add directory="../cbp2make/lib" />
<Add directory="../cbp2make/lib/tinyxml" />
<Add directory="../cbp2make/src" />
<Add directory="D:/vc/wxWidgets-3.2.7/include" />
<Add directory="D:/vc/wxWidgets-3.2.7/include/msys" />
<Add directory="lib" />
<Add directory="src" />
</Compiler>
<Linker>
<Add option="-m64" />
<!-- 正确的库搜索路径 -->
<Add directory="D:/vc/wxWidgets-3.2.7/lib" />
<!-- 正确的库引用 -->
<Add library="wx_mswu_adv-3.2" />
<Add library="wxscintilla-3.2" />
</Linker>
	<!-- AI 增强独有的文件 -->
	<Unit filename="src/aicoder_enhancements.cpp" />
	
	<!-- 引用原 cbp2make 的核心文件 -->
	<Unit filename="../cbp2make/src/cbp2make.cpp" />
	<Unit filename="../cbp2make/src/cbproject.cpp" />
	<Unit filename="../cbp2make/src/cbworkspace.cpp" />
	<Unit filename="../cbp2make/src/makefile.cpp" />
	<Unit filename="../cbp2make/src/cbptarget.cpp" />
	<Unit filename="../cbp2make/src/cbpunit.cpp" />
	<Unit filename="../cbp2make/src/cbbuildcfg.cpp" />
	<Unit filename="../cbp2make/src/cbbuildmgr.cpp" />
	<Unit filename="../cbp2make/src/cbglobalvar.cpp" />
	<Unit filename="../cbp2make/src/cbhelper.cpp" />
	<Unit filename="../cbp2make/src/depsearch.cpp" />
	<Unit filename="../cbp2make/src/platforms.cpp" />
	<Unit filename="../cbp2make/src/toolchains.cpp" />
	<Unit filename="../cbp2make/src/buildtools.cpp" />
	
	<!-- 引用原 cbp2make 的库文件 -->
	<Unit filename="../cbp2make/lib/stlconfig.cpp" />
	<Unit filename="../cbp2make/lib/stlconvert.cpp" />
	<Unit filename="../cbp2make/lib/stlfutils.cpp" />
	<Unit filename="../cbp2make/lib/stlgpm.cpp" />
	<Unit filename="../cbp2make/lib/stlstrings.cpp" />
	<Unit filename="../cbp2make/lib/stlvariables.cpp" />
	<Unit filename="../cbp2make/lib/stringhash.cpp" />
	<Unit filename="../cbp2make/lib/tinyxml/tinystr.cpp" />
	<Unit filename="../cbp2make/lib/tinyxml/tinyxml.cpp" />
	<Unit filename="../cbp2make/lib/tinyxml/tinyxmlerror.cpp" />
	<Unit filename="../cbp2make/lib/tinyxml/tinyxmlparser.cpp" />
</Project>
</CodeBlocks_project_file>
CPBEOF

echo "✅ 项目文件已重新创建"
